|
|
|
|
|
|
|
having returns as part of your postcondition behavior. Subs are used when postcondition processing isn't required, such as the simple setting of a property's value (although certain applications might even need to process the integrity of a built-in data type). Now back to the example. |
|
|
|
|
|
|
|
|
Figure 4.3 illustrates the interaction between the bank teller, the theDeposit object, and theBasicPersonalCheckingAccount object. Using its depositFunds method as its operational starting point, the theDeposit object communicates with the theBasicPersonalCheckingAccount object via the latter object's adjustBalance method. The adjustBalance method accepts two arguments, the object reference of the client object (theDeposit, in this case) and the actual account number of the account to which the deposit is to be applied. |
|
|
|
|
|
|
|
|
Figure 4.3.
A sequence diagram showing the interaction between the
bank teller, the theDeposit object, and
the theBasicPersonalChecking
Account object. |
|
|
|
|
|
|
|
|
The adjustBalance method of the theBasicPersonalCheckingAccount object is interesting. At the top of the method body is a declaration of a local object variable called LocalObject. The purpose of this object variable is to localize the reference to the object represented by the argument argObject. The next few lines of code, included in the IfThen statement, perform a precondition check to ensure that the object is the proper target for receiving the message. The qualifier is the AccountNumber value. If the account number passed in isn't equal to the account number of theBasicPersonalCheckingAccount object, an exception is raised and the operation is stopped. If the account number values are equal, the operation continues. |
|
|
|
|
|